define(['jquery',
    'underscore',
    'handlebar',
    'backbone',   
    '../../collection/category/Ccategory',   
    'text!../../../templates/common/detailsProductInfo.html',
    'GlobalConfiguration',
],
        function($,
                Underscore,
                Handlebar,
                Backbone,
                CollectoionCategory,              
                detailsProductInfoTemplate,
                GConfigs
                ) {

            var VItemsRow = Backbone.View.extend({               
                el: $('section#items-row'),
               
                fetchDetailedProductInfo: function (prodId)
                {                                      
                    var URL = GConfigs.CONSTANTS.PROTOCOL + "://" + GConfigs.CONSTANTS.HOST_NAME + ":" + GConfigs.CONSTANTS.PORT_NO + GConfigs.CONSTANTS.REST_PATH + GConfigs.API.fetchDetailedProductInfo
                    var self = this;
                    $.ajax({                        
                        url: URL,
                        dataType: 'json',
                        data: {
                            'prodId':prodId
                        },
                        success:function(responce)
                        {
                            self.renderUI(responce.rows);
                        },
                        error: function (err) {
                            console.log('ERROR',err)
                        }
                    });                    
                },
                renderUI: function (responce)
                {                   
                    var detailsProductTemplate = Handlebars.compile(detailsProductInfoTemplate);
                    var detailsProductTemplateDOM = detailsProductTemplate(responce);            
                    this.$el.html(detailsProductTemplateDOM)
                },
                events: {
                    'click #btnBackToSerchVIew': 'reloadProductSearchView',
                    'click #myTab a': 'navigateBtwTabs'
                },
                reloadProductSearchView: function (e) {
                    //show filter;       
                    var appView = new AppView();
                    appView.showLeftPanel();
                    
                    this.removeProducrDetailsView();                   
                },
                removeProducrDetailsView:function(){                    
                    $(this.el).empty();
                    this.renderSearchProductView();
                },                
                renderSearchProductView: function () {                    
                    //console.log(window.placeId + "--------" + window.itemName)
                    window.vProducts.searchByItem(window.placeId, window.itemName)
                },
                navigateBtwTabs: function (e)
                {
                    
                    if ($(this).parent('li').hasClass('active')) {
                        $($(this).attr('href')).hide();
                    }
                    else {
                        e.preventDefault();
                        $(this).tab('show');
                    }

                }
            });
            return VItemsRow;
        });

